package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-11-14
 * Time: 15:08
 */
public class ReturnOperation implements IOPeration{


    @Override
    public void work(Booklist booklist) {


        System.out.println("*******  归还图书:  *******");

        System.out.println("***** 请输入要借阅图书: *****");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int currentSize = booklist.getUsedsize();

        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getbook(i);
            if (book.getName().equals(name)) {
                book.setIsborrowed(false);
                System.out.println("*******  归还成功!  *******");
                System.out.println(book);
                return;
            }
        }
    }
}
